{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def DetectNight2(RGB_image):\n",
    "    totalPixels = RGB_image.shape[0] * RGB_image.shape[1]\n",
    "    hsv = cv2.cvtColor(RGB_image,cv2.COLOR_BGR2HSV)\n",
    "    h,s,v = cv2.split(hsv)\n",
    "    nonzero = cv2.countNonZero(v)\n",
    "    zeroPixel = totalPixels - nonzero\n",
    "    print(totalPixels)\n",
    "    print(\"ZeroPixel: \",zeroPixel)\n",
    "    print(zeroPixel/totalPixels)\n",
    "    cv2.imshow(\"V\",v)\n",
    "    cv2.waitKey(0)\n",
    "    cv2.destroyAllWindows()\n",
    "    if zeroPixel > (totalPixels/5):\n",
    "        #print(\"NIGHT\")\n",
    "        return True #if like night\n",
    "    else:\n",
    "        #print(\"DAY\") #if like day\n",
    "        return False"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
